package model;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.service.ServiceRegistryBuilder;

/* 
 * Manager reads a next row from table and 
 * submits a new thread Handler, passing Destination
 * and Message *to* this thread and taking a Reply *from*
 * to record in the third column of the corresponding
 * row table.
 */

public class Manager implements Runnable {

	@Override
	public void run() {
		Configuration configuration = new Configuration();
		configuration.configure();
		ServiceRegistry serviceRegistry = new ServiceRegistryBuilder().applySettings(configuration.getProperties()).buildServiceRegistry();
		SessionFactory sessionFactory = configuration.buildSessionFactory(serviceRegistry);
		
		Session session = sessionFactory.openSession();
		session.beginTransaction();
		//List<Tab> messages = (List<Tab>)session.createQuery("from messagestable order by Id").list();
		
		Criteria crit = session.createCriteria(Tab.class);
		crit.setMaxResults(100);
		List<Tab> messages = crit.list();
		
	}

}
